<template>
	<view class="content" v-if="pageshow">
		<view class="padding">
			<view class="">
				<!-- 订单状态 -->
				<view class="bigtext" >{{orderDetail.checkinfo_type_text}}</view>
				<view class="strongtext margin_top2" v-if="orderDetail.checkinfo_type==30">拒绝原因：{{orderDetail.error_reason}}</view>
			</view>
			<!-- 地址 -->
			<view class="padding ffffff border_2 margin_top" v-if="orderDetail.checkinfo_type==20">
				<view class="flexleft">
					<view class=" word_baiba black margin_right3">{{orderDetail.shop.return_name}}</view>
					<view class=" word_baiba black">{{orderDetail.shop.return_phone}}</view>
				</view>
				<view class="huisetext margin_top2">{{orderDetail.shop.return_region}}{{orderDetail.shop.return_addr}}</view>
			</view>
			<!-- 商品 -->
			<view class="" style="padding-bottom:120rpx;">
				<view class="ffffff padding border_2 margin_top">
					<view class="flexleft">
						<image class="imgShop margin_right1" src="/static/image/mine/dianpuRed.png" mode="widthFix"></image>
						<view class="color_ling text_z margin_right1">{{orderDetail.shop.shop_name}}</view>
						<u-icon name="arrow-right" color="rgba(153, 153, 153, 1)" size="12"></u-icon>
					</view>
					<view class=" xiahuax margin_top"  v-for="item in orderDetail.refundgoods" :key="item.id">
						<view class="flexbetween">
							<view class="shilitu">
								<image :src="item.ordergoods.goods_image_text" mode="widthFix"></image>
							</view>
							<view class="" style="width: 74%;">
								<view class="ershib yhxiank">{{item.ordergoods.goods_name}}</view>
								<view class="margin_top1 white">{{item.ordergoods.sku}}</view>
								<view class="flexbetween margin_top1">
									<view class="qianshu">¥{{item.ordergoods.total_price}}</view>
									<view class="shuliang">X{{item.ordergoods.goods_num}}</view>
								</view>
							</view>
						</view>
					</view>
				</view>
				<!-- 商品详情 -->
				<view class="paddingbom">
					<view class="ffffff padding border_2 margin_top">
						<view class="flexbetween margin_top">
							<view class="tuihuo">退货订单编号</view>
							<view class="huisetext">{{orderDetail.refund_no}}</view>
						</view>
						<view class="flexbetween margin_top">
							<view class="tuihuo">退货申请时间</view>
							<view class="huisetext">{{orderDetail.createtime_text}}</view>
						</view>
						<view class="flexbetween margin_top">
							<view class="tuihuo">退款原因</view>
							<view class="huisetext">{{orderDetail.refund_reason}}</view>
						</view>
						<view class="flexbetween margin_top">
							<view class="tuihuo">退款金额</view>
							<view class="huisetext">{{orderDetail.refund_money}}</view>
						</view>
						<view class="flexbetween margin_top" v-if="orderDetail.refund_content">
							<view class="tuihuo">备注</view>
							<view class="huisetext">{{orderDetail.refund_content}}</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 固定底部 -->
			<view class="flexright gddb margin_top ">
				<view class="huisebtn" v-show="orderDetail.can_cancel"
					@click.stop="cancelorder(orderDetail.id)">取消申请
				</view>
				<view class="huisebtn margin_left3"  v-show="orderDetail.can_express"  @click.stop="goLogisticsInfo">查看物流</view>
				<view class="huangsebtn margin_left3"  v-show="orderDetail.can_deliver"  @click.stop="submitNo(orderID)">填写单号</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				orderID: '', // 订单 id
				orderDetail: {}, // 订单详情内容
				pageshow: false,
				qrcodeurl: '',
			}
		},
		onLoad(options) {
			let _this = this
			_this.orderID = options.id
		},
		onShow() {
			let _this = this
			_this.getOrderInfo()
		},
		methods: {
			goLogisticsInfo(){ //查看物流
				uni.navigateTo({
					url:"./logisticsInfo"
				})
			},
			// 获取订单详情
			getOrderInfo() {
				let _this = this
				httpRequest.request('/api/goods_refund/getdetail', 'GET', {
					order_refund_id: _this.orderID
				}).then(res => {
					if (res.code == 1) {
						_this.orderDetail = res.data
						this.pageshow = true
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			// 取消订单
			cancelorder(id) {
				httpRequest.modal('提示', '确定取消当前申请吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/goods_refund/cancel', 'POST', {
							order_refund_id: id,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								this.getOrderInfo()
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			
			// 删除订单
			deletorder() {
				httpRequest.modal('提示', '确定删除当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('api/order/delOrder', 'POST', {
							id: this.orderID,
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg);
							if (res.code == 1) {
								uni.navigateBack(1)
							}
						}).catch(err => {
							httpRequest.toast(err.msg);
						})
					}
				})
			},
			submitNo(id){
				uni.navigateTo({
					url:"/pages_mine/onceSendGoods?id="+id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.gddb{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 30rpx;
		box-sizing: border-box;
	}
	.imgShop{
		width: 26.62rpx;
		height: 24rpx;
	}
	.dan {
		width: 80vw;
		padding: 64rpx 40rpx 0rpx 40rpx;
	}
	.tuihuo {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}

	.money_tui {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #D48B39;
	}

	.order {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.hexiao {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}

	.white {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.erwie {
		width: 169rpx;
		height: 169rpx;
	}

	.code {
		padding: 30rpx 30rpx;
		margin-top: 30rpx;
		background-color: #fff;
	}

	::v-deep.u-safe-area-inset-bottom {
		padding-bottom: 0;
		padding-bottom: constant(safe-area-inset-bottom);
	}

	.fuzhi {
		padding: 0rpx 100rpx;
	}

	.copy {
		padding: 20rpx 40rpx;
		border-radius: 51rpx;
		background-color: rgba(212, 139, 57, 1);
		margin-top: 109rpx;
		color: #fff;
	}

	.dan {
		padding: 64rpx 40rpx 64rpx 40rpx;
	}

	.zhongtong {
		margin-top: 87rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
		padding: 34rpx 82rpx;
		border: 1rpx solid rgba(223, 223, 223, 1);
		border-radius: 10rpx;
	}

	.wuliu {
		font-size: 40rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #000000;
	}

	.strongtext {
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.bigtext {
		font-size: 34rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.xzqianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: rgba(212, 139, 57, 1);
	}

	.huangsebtn {
		border: 2rpx solid  rgba(243, 39, 28, 1);
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color:  rgba(243, 39, 28, 1);
	}

	.huisebtn {
		border: 2rpx solid #666666;
		width: 170rpx;
		height: 67rpx;
		display: flex;
		border-radius: 120rpx;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.shuliang {
		font-size: 26rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #999999;
	}

	.ershib {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.shilitu {
		width: 134rpx;
		height: 128rpx;
		border-radius: 14rpx;
 overflow: hidden;
		image {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.qianshu {
		font-size: 28rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: rgba(243, 39, 28, 1);
	}

	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.yhxiank {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.paddingbom {
		padding-bottom: 150rpx;
	}
</style>